home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 August / MW 8 2003 CD1.iso / Inside Macworld / Product News / gimp-1.2.4.sit / gimp-1.2.4 / plug-ins / perl / examples / scratches < prev    next >
Encoding:
Text File  |  2000-05-21  |  1.9 KB  |  63 lines

  1. #!/usr/app/bin/perl
  2.  
  3. eval 'exec /usr/app/bin/perl  -S $0 ${1+"$@"}'
  4.     if 0; # not running under some shell
  5.  
  6. use Gimp;
  7. use Gimp::Fu;
  8. use Gimp::Util;
  9.  
  10. sub new_scratchlayer {
  11.     my($image,$length,$gamma,$angle)=@_;
  12.     my $type=$image->layertype(0);
  13.     my($layer)=$image->layer_new ($image->width, $image->height, $image->layertype(0),
  14.                                   "displace layer ($angle)", 100, NORMAL_MODE);
  15.     $layer->add_layer(-1);
  16.     $layer->fill (WHITE_IMAGE_FILL);
  17.     $layer->noisify (0, 1, 1, 1, 0);
  18.     $layer->mblur (0, $length, $angle);
  19.     #$layer->levels (VALUE_LUT, 120, 255, $gamma, 0, 255);
  20.     $layer->levels (VALUE_LUT, 120, 255, 0.3, 0, 255);
  21.  
  22.     $layer;
  23. }
  24.  
  25. register "scratches",
  26.          "Create a scratch effect",
  27.          "Add scratches to an existing image. Works best on a metallic-like background.",
  28.          "Marc Lehmann",
  29.          "Marc Lehmann <pcg\@goof.com>",
  30.          "19990223",
  31.          N_"<Image>/Filters/Distorts/Scratches...",
  32.          "*",
  33.          [
  34.           [PF_SLIDER    , "angle_x"    , "The horizontal angle"    ,  30, [  0, 360]],
  35.           [PF_SLIDER    , "angle_y"    , "The vertical angle"        ,  70, [  0, 360]],
  36.           [PF_SLIDER    , "gamma"    , "Scratch map gamma"        , 0.3, [0.1,  10, 0.05]],
  37.           [PF_SPINNER    , "smoothness"    , "The scratch smoothness"    ,  15, [  0, 400]],
  38.           [PF_SPINNER    , "length"    , "The scratch length"        ,  10, [  0, 400]],
  39.           #[PF_BOOL,    , "bump_map"    , "Use bump map instead of displace", 0],
  40.          ],
  41.          [],
  42.          ['gimp-1.1'],
  43.          sub {
  44.    my($image,$drawable,$anglex,$angley,$gamma,$length,$width)=@_;
  45.  
  46.    $image->undo_push_group_start;
  47.  
  48.    my $layer1 = new_scratchlayer ($image, $length, $gamma, $anglex);
  49.    my $layer2 = new_scratchlayer ($image, $length, $gamma, $angley);
  50.  
  51.    $drawable->displace ($width, $width, 1, 1, $layer1, $layer2, WRAP);
  52.  
  53.    $layer1->remove_layer;
  54.    $layer2->remove_layer;
  55.  
  56.    $image->undo_push_group_end;
  57.  
  58.    $image;
  59. };
  60.  
  61. exit main;
  62.  
  63.